Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce torch_xla.launch() #7648

Merged
merged 4 commits into from
Jul 12, 2024
Merged

Introduce torch_xla.launch() #7648

merged 4 commits into from
Jul 12, 2024

Conversation

zpcore
Copy link
Collaborator

@zpcore zpcore commented Jul 9, 2024

Draft of using torch_xla.launch() for torchrun and xmp.spawn()

Unify _mp_fn(xu.getenv_as(xenv.LOCAL_RANK, int), FLAGS) (call with torchrun) or
xmp.spawn(_mp_fn, args=(FLAGS,), nprocs=FLAGS.num_cores)
with

torch_xla.launch(_mp_fn, args=(FLAGS,) , nprocs=FLAGS.num_cores)

@zpcore zpcore changed the title experimental Introduce torch_xla.launch() Jul 9, 2024
@zpcore zpcore marked this pull request as ready for review July 11, 2024 01:16
@zpcore zpcore requested review from will-cromar and JackCaoG July 11, 2024 01:22
Copy link
Collaborator

@will-cromar will-cromar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thank you for implementing this 😄

dist.init_process_group('xla', init_method='xla://')
super().__init__()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should the super init stay at the top?

Copy link
Collaborator Author

@zpcore zpcore Jul 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, super().__init__() will call some functions from runtime, which needs init the TPU backend first.

@zpcore zpcore merged commit 5b8e8e0 into master Jul 12, 2024
23 checks passed
@zpcore zpcore deleted the piz/launch branch July 24, 2024 23:27
@miladm miladm added the usability Bugs/features related to improving the usability of PyTorch/XLA label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
usability Bugs/features related to improving the usability of PyTorch/XLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants